package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightDeliverPostorder;
import com.ktgj.flight.service.IFlightDeliverPostorderService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 会员邮寄订单明细Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/postorder")
public class FlightDeliverPostorderController extends BaseController
{
    @Autowired
    private IFlightDeliverPostorderService flightDeliverPostorderService;

    /**
     * 查询会员邮寄订单明细列表
     */
    @PreAuthorize(hasPermi = "flight:postorder:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightDeliverPostorder flightDeliverPostorder)
    {
        startPage();
        List<FlightDeliverPostorder> list = flightDeliverPostorderService.selectFlightDeliverPostorderList(flightDeliverPostorder);
        return getDataTable(list);
    }

    /**
     * 导出会员邮寄订单明细列表
     */
    @PreAuthorize(hasPermi = "flight:postorder:export")
    @Log(title = "会员邮寄订单明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightDeliverPostorder flightDeliverPostorder) throws IOException
    {
        List<FlightDeliverPostorder> list = flightDeliverPostorderService.selectFlightDeliverPostorderList(flightDeliverPostorder);
        ExcelUtil<FlightDeliverPostorder> util = new ExcelUtil<FlightDeliverPostorder>(FlightDeliverPostorder.class);
        util.exportExcel(response, list, "会员邮寄订单明细数据");
    }

    /**
     * 获取会员邮寄订单明细详细信息
     */
    @PreAuthorize(hasPermi = "flight:postorder:query")
    @GetMapping(value = "/{deliverPostorderId}")
    public AjaxResult getInfo(@PathVariable("deliverPostorderId") Long deliverPostorderId)
    {
        return AjaxResult.success(flightDeliverPostorderService.selectFlightDeliverPostorderById(deliverPostorderId));
    }

    /**
     * 新增会员邮寄订单明细
     */
    @PreAuthorize(hasPermi = "flight:postorder:add")
    @Log(title = "会员邮寄订单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightDeliverPostorder flightDeliverPostorder)
    {
        return toAjax(flightDeliverPostorderService.insertFlightDeliverPostorder(flightDeliverPostorder));
    }

    /**
     * 修改会员邮寄订单明细
     */
    @PreAuthorize(hasPermi = "flight:postorder:edit")
    @Log(title = "会员邮寄订单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightDeliverPostorder flightDeliverPostorder)
    {
        return toAjax(flightDeliverPostorderService.updateFlightDeliverPostorder(flightDeliverPostorder));
    }

    /**
     * 删除会员邮寄订单明细
     */
    @PreAuthorize(hasPermi = "flight:postorder:remove")
    @Log(title = "会员邮寄订单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deliverPostorderIds}")
    public AjaxResult remove(@PathVariable Long[] deliverPostorderIds)
    {
        return toAjax(flightDeliverPostorderService.deleteFlightDeliverPostorderByIds(deliverPostorderIds));
    }
}
